﻿using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace BackupRestoreSoftwares.FormChild
{
    public partial class m_Restore : UserControl
    {
        private readonly string App_path = Application.StartupPath;
        private readonly bool Is64 = Environment.Is64BitOperatingSystem;
        private readonly string Local_path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
        private readonly string Program_32 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
        private readonly string Program_64 = Path.GetPathRoot(Environment.SystemDirectory) + "Program Files";
        private readonly string Roaming_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        private string Common_path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

        public m_Restore()
        {
            InitializeComponent();
        }

        private void m_Restore_Load(object sender, EventArgs e)
        {
        }

        private void Import(string registryPath)
        {
            string key = "\"" + registryPath + "\"";
            var proc = new Process();
            try
            {
                proc.StartInfo.FileName = "regedit.exe";
                proc.StartInfo.UseShellExecute = false;

                proc = Process.Start("regedit.exe", "/s " + key + "");
                proc.WaitForExit();
            }
            catch (Exception)
            {
                proc.Dispose();
            }
        }

        #region Button

        private void btn_res_notepad_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Notepad++");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_32 + @"\Notepad++\notepad++.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "notepad++")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Notepad++\Notepad++.rar";
                        string path_file = Roaming_path + @"\Notepad++\";
                        EasyRAR.Extract(rar_file, path_file);
                        string rar_file_plug = App_path + @"\DBBACKUP\Notepad++\plugins.rar";
                        string path_file_plug = Program_32 + @"\Notepad++\plugins\";
                        EasyRAR.Extract(rar_file_plug, path_file_plug);

                        t.Abort();
                        EasyDialog.ShowSuccessRestore("Notepad++");
                    }
                    else
                    {
                        t.Abort();
                        EasyDialog.ShowNotinstall("Notepad++");
                    }
                }
                catch
                {
                    EasyDialog.ShowContact();
                }
            }
        }

        private void btn_res_sublime_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Sublime Text");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    if (Is64)
                    {
                        string chkfile_64 = Program_64 + @"\Sublime Text 2\sublime_text.exe";
                        string chkfile_32 = Program_32 + @"\Sublime Text 2\sublime_text.exe";
                        if (File.Exists(chkfile_64) || File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "sublime_text")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\SublimeText2\Sublime2.rar";
                            string path_file = Roaming_path + @"\Sublime Text 2\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Sublime Text 2 don't install!", "Error");
                        }
                    }
                    else
                    {
                        string chkfile_32 = Program_32 + @"\Sublime Text 2\sublime_text.exe";
                        if (File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "sublime_text")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\SublimeText2\Sublime2.rar";
                            string path_file = Roaming_path + @"\Sublime Text 2\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Sublime Text 2 don't install!", "Error");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_subtext3_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Sublime Text 3");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    if (Is64)
                    {
                        string chkfile_64 = Program_64 + @"\Sublime Text 3\sublime_text.exe";
                        string chkfile_32 = Program_32 + @"\Sublime Text 3\sublime_text.exe";
                        if (File.Exists(chkfile_64) || File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "sublime_text")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\SublimeText3\Sublime3.rar";
                            string path_file = Roaming_path + @"\Sublime Text 3\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Sublime Text 3 don't install!", "Error");
                        }
                    }
                    else
                    {
                        string chkfile_32 = Program_32 + @"\Sublime Text 3\sublime_text.exe";
                        if (File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "sublime_text")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\SublimeText3\Sublime3.rar";
                            string path_file = Roaming_path + @"\Sublime Text 3\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Sublime Text 3 don't install!", "Error");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_chrome_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Chrome");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_32 + @"\Google\Chrome\Application\chrome.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "chrome")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Chrome\User_Data.rar";
                        string path_file = Local_path + @"\Google\Chrome\User Data\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Chrome don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_opera_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Opera Browser");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    if (Is64)
                    {
                        string chkfile_64 = Program_64 + @"\Opera\launcher.exe";
                        string chkfile_32 = Program_32 + @"\Opera\launcher.exe";
                        if (File.Exists(chkfile_64) || File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "opera")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\Opera\Opera_Data.rar";
                            string path_file = Roaming_path + @"\Opera Software\Opera Stable\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Opera Browser don't install!", "Error");
                        }
                    }
                    else
                    {
                        string chkfile_32 = Program_32 + @"\Opera\launcher.exe";
                        if (File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "opera")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\Opera\Opera_Data.rar";
                            string path_file = Roaming_path + @"\Opera Software\Opera Stable\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Opera Browser don't install!", "Error");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_firefox_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Firefox");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_32 + @"\Mozilla Firefox\firefox.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "firefox")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Firefox\Firefox_Data.rar";
                        string path_file = Roaming_path + @"\Mozilla\Firefox\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Mozilla Firefox don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_corom_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Coc Coc");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Local_path + @"\CocCoc\Browser\Application\browser.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "browser")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\CoRom\CoRom_Data.rar";
                        string path_file = Local_path + @"\CocCoc\Browser\User Data\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("CoRom+ don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_phpdesign_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("phpDesigner");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_32 + @"\phpDesigner 8\phpDesigner.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "phpDesigner")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\phpDesigner\phpDesigner_Data.rar";
                        string path_file = Roaming_path + @"\phpDesigner\";
                        EasyRAR.Extract(rar_file, path_file);
                        File.Copy(App_path + @"\DBBACKUP\phpDesigner\phpdesigner.xml",
                            Roaming_path + @"\phpdesigner.xml", true);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("phpDesigner 8 don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_corelx6_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Corel X6");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    if (Is64)
                    {
                        string chkfile_64 = Program_64 + @"\Corel\CorelDRAW Graphics Suite X6\Programs64\CorelDRW.exe";
                        ;
                        if (File.Exists(chkfile_64))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "CorelDRW")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\CorelDraw\CorelX6.rar";
                            string path_file = Roaming_path + @"\Corel\CorelDRAW Graphics Suite X6\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Corel Draw X6 don't install!", "Error");
                        }
                    }
                    else
                    {
                        string chkfile_32 = Program_32 + @"\Corel\CorelDRAW Graphics Suite X6\Programs\CorelDRW.exe";
                        if (File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "CorelDRW")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\CorelDraw\CorelX6.rar";
                            string path_file = Roaming_path + @"\Corel\CorelDRAW Graphics Suite X6\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Corel Draw X6 don't install!", "Error");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_snippet_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Snippets");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_32 + @"\Snippets\Snippets.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "Snippets")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Snippets\Snippets_Data.rar";
                        string path_file = Local_path + @"\Snippets\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Snippets don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_evernote_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Evernote");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_32 + @"\Evernote\Evernote\Evernote.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "Evernote")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Evernote\Evernote_Data.rar";
                        string path_file = Local_path + @"\Evernote\Evernote\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Evernote don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_corelx4_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Corel X4");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile_32 = Program_32 + @"\Corel\CorelDRAW Graphics Suite X4\Programs\CorelDRW.exe";
                    if (File.Exists(chkfile_32))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "CorelDRW")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\CorelDraw\CorelX4.rar";
                        string path_file = Roaming_path + @"\Corel\Graphics13\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Corel Draw X3 don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_pts7_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Photoshop");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile_32 = Program_32 + @"\Adobe\Photoshop 7.0\Photoshop.exe";
                    if (File.Exists(chkfile_32))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "photoshop")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Photoshop\PTS7.rar";
                        string path_file = Roaming_path + @"\Adobe\Photoshop\7.0\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Adobe Photoshop 7 don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_pts9_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Photoshop 9");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile_32 = Program_32 + @"\Adobe\Adobe Photoshop CS2\Photoshop.exe";
                    if (File.Exists(chkfile_32))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "photoshop")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Photoshop\PTS9.rar";
                        string path_file = Roaming_path + @"\Adobe\Photoshop\9.0\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Adobe Photoshop 9 don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_cs4_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Photoshop CS4");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile_32 = Program_32 + @"\Adobe\Photoshop cs4\Photoshop.exe";
                    if (File.Exists(chkfile_32))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "photoshop")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Photoshop\PTSCS4.rar";
                        string path_file = Roaming_path + @"\Adobe\Adobe Photoshop CS4\Adobe Photoshop CS4 Settings\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Adobe Photoshop CS 4 don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_cs6_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Photoshop CS5");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    if (Is64)
                    {
                        string chkfile_64 = Program_64 + @"\Adobe\Adobe Photoshop CS6 (64 Bit)\Photoshop.exe";
                        string chkfile_32 = Program_32 + @"\Adobe\Photoshop CS6\Photoshop.exe";
                        if (File.Exists(chkfile_64) || File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "photoshop")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\Photoshop\PTSCS6.rar";
                            string path_file = Roaming_path +
                                               @"\Adobe\Adobe Photoshop CS6\Adobe Photoshop CS6 Settings\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Adobe Photoshop CS6 don't install!", "Error");
                        }
                    }
                    else
                    {
                        string chkfile_32 = Program_32 + @"\Adobe\Photoshop CS6\Photoshop.exe";
                        if (File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "photoshop")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\Photoshop\PTSCS6.rar";
                            string path_file = Roaming_path +
                                               @"\Adobe\Adobe Photoshop CS6\Adobe Photoshop CS6 Settings\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Adobe Photoshop CS6 don't install!", "Error");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_ptscc_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Photoshop CS CC");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    if (Is64)
                    {
                        string chkfile_64 = Program_64 + @"\Adobe\Adobe Photoshop CC (64 Bit)\Photoshop.exe";
                        string chkfile_32 = Program_32 + @"\Adobe\Photoshop CC\Photoshop.exe";
                        if (File.Exists(chkfile_64) || File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "photoshop")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\Photoshop\PTSCC.rar";
                            string path_file = Roaming_path + @"\Adobe\Adobe Photoshop CC\Adobe Photoshop CC Settings\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Adobe Photoshop CC don't install!", "Error");
                        }
                    }
                    else
                    {
                        string chkfile_32 = Program_32 + @"\Adobe\Photoshop CC\Photoshop.exe";
                        if (File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "photoshop")
                                    app.Kill();
                            string rar_file = App_path + @"\DBBACKUP\Photoshop\PTSCC.rar";
                            string path_file = Roaming_path + @"\Adobe\Adobe Photoshop CC\Adobe Photoshop CC Settings\";
                            EasyRAR.Extract(rar_file, path_file);

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("Adobe Photoshop CC don't install!", "Error");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_neat6_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("NeatImage 6.0");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile_32 = Program_32 + @"\Neat Image\NeatImage.exe";
                    if (File.Exists(chkfile_32))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "NeatImage")
                                app.Kill();
                        string rar_file = App_path + @"\DBBACKUP\Neatimage\Neat.rar";
                        string path_file = Roaming_path + @"\Neat Image\PRESETS\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("Neatimage 6 don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_idm_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Internet Download Manager");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_32 + @"\Internet Download Manager\IDMan.exe";
                    if (File.Exists(chkfile))
                    {
                        foreach (Process app in Process.GetProcesses())
                            if (app.ProcessName == "IDMan")
                                app.Kill();

                        Import(App_path + @"\DBBACKUP\IDMSetting.reg");
                        t.Abort();
                        MessageBox.Show("Restore completed!", "Finish");
                    }
                    else
                    {
                        t.Abort();
                        MessageBox.Show("IDM don't install!", "Error");
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_winrar_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("Winrar");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    if (Is64)
                    {
                        string chkfile_64 = Program_64 + @"\WinRAR\WinRAR.exe";
                        string chkfile_32 = Program_32 + @"\WinRAR\WinRAR.exe";
                        if (File.Exists(chkfile_64) || File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "WinRAR")
                                    app.Kill();
                            Import(App_path + @"\WinRARSetting.reg");

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("WinRAR don't install!", "Error");
                        }
                    }
                    else
                    {
                        string chkfile_32 = Program_32 + @"\WinRAR\WinRAR.exe";
                        if (File.Exists(chkfile_32))
                        {
                            foreach (Process app in Process.GetProcesses())
                                if (app.ProcessName == "WinRAR")
                                    app.Kill();
                            Import(App_path + @"\WinRARSetting.reg");

                            t.Abort();
                            MessageBox.Show("Restore completed!", "Finish");
                        }
                        else
                        {
                            t.Abort();
                            MessageBox.Show("WinRAR don't install!", "Error");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error! Please contact: caiwindao@outlook.com", "Error");
                }
            }
        }

        private void btn_res_svn_Click(object sender, EventArgs e)
        {
            DialogResult result = EasyDialog.ShowYesNoRestore("TortoiseSVN");
            if (result == DialogResult.Yes)
            {
                try
                {
                    var t = new Thread(frmMain.waitscreen);
                    t.Start();

                    string chkfile = Program_64 + @"\TortoiseSVN\bin\TortoiseProc.exe";
                    if (File.Exists(chkfile))
                    {
                        string rar_file = App_path + @"\DBBACKUP\TortoiseSVN\Subversion.rar";
                        string path_file = Roaming_path + @"\Subversion\";
                        EasyRAR.Extract(rar_file, path_file);

                        t.Abort();
                        EasyDialog.ShowSuccessRestore("TortoiseSVN");
                    }
                    else
                    {
                        t.Abort();
                        EasyDialog.ShowNotinstall("TortoiseSVN");
                    }
                }
                catch
                {
                    EasyDialog.ShowContact();
                }
            }
        }

        #endregion
    }
}